<%@ Page Language="C#" MasterPageFile="~/Default.master" AutoEventWireup="true" CodeFile="ImageCompetition.aspx.cs"
    Inherits="Templates_ImageCompetition" Title="Untitled Page" %>

<asp:Content ID="Content1" ContentPlaceHolderID="cphHeader" runat="Server">
    <acms:FlashContentControlDisplay ID="flashHeader" ControlName="FlashHeader" WMode="Transparent"
        MaxWidth="800" runat="server" />
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="cphBody" runat="Server">
    <acms:FlashContentControlDisplay ID="flashIntro" ControlName="FlashIntro" WMode="Transparent"
        MaxWidth="500" runat="server" />
    <acms:ImageContentControlDisplay ID="imageIntro" ControlName="ImageIntro" runat="server" />
            <asp:LoginView ID="viewEnter" runat="server" OnDataBinding="viewEnter_DataBinding" Visible="false">
                <LoggedInTemplate>
                    <asp:Panel ID="pnlNotEntered" CssClass="htmlArticle" runat="server">
                        <h3>
                            Enter the competition:</h3>
                        <asp:Panel ID="pnlFileError" EnableViewState="false" Visible="false" CssClass="error"
                            runat="server">
                            Invalid file. Only image files less that 3MB in size may be uploaded.
                        </asp:Panel>
                        <asp:Label ID="lblTitle" runat="server" Text="Title" AssociatedControlID="txtTitle"></asp:Label><br />
                        <asp:TextBox ID="txtTitle" runat="server" Columns="50" MaxLength="500"></asp:TextBox><br />
                        <asp:RequiredFieldValidator ID="valTitle" runat="server" ControlToValidate="txtTitle"
                            Display="Dynamic" ErrorMessage="Required<br/>" ValidationGroup="EnterCompetition"></asp:RequiredFieldValidator><br />
                        <asp:Label ID="lblComment" runat="server" Text="Comment" AssociatedControlID="txtComment"></asp:Label><br />
                        <asp:TextBox ID="txtComment" runat="server" Columns="40" TextMode="MultiLine" Rows="5"
                            MaxLength="2000"></asp:TextBox><br />
                        <asp:RequiredFieldValidator ID="valCommentReq" runat="server" ControlToValidate="txtComment"
                            Display="Dynamic" ErrorMessage="Required<br/>" ValidationGroup="EnterCompetition"></asp:RequiredFieldValidator><br />
                        <asp:Label ID="lblFile" runat="server" AssociatedControlID="fuImage" Text="Image"></asp:Label><br />
                        <asp:FileUpload ID="fuImage" runat="server" /><br />
                        <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="fuImage"
                            Display="Dynamic" ErrorMessage="Required<br/>" ValidationGroup="EnterCompetition"></asp:RequiredFieldValidator><br />
                        <asp:Button ID="btnEnter" runat="server" Text="Enter" OnClick="btnEnter_Click" ValidationGroup="EnterCompetition" />
                    </asp:Panel>
                    <asp:Panel ID="pnlEntered" CssClass="htmlArticle" runat="server">
                        <h2>You have entered this competition!</h2>
                        <p>
                            <asp:LinkButton ID="btnViewEntry" Text="View your entry" runat="server" OnClick="btnViewEntry_Click" /></p>
                        <p>
                            <asp:LinkButton ID="btnDeleteEntry" OnClientClick="return confirm('Are you sure you want to delete your entry to this competition?');" Text="Delete your entry" OnClick="btnDeleteEntry_Click"
                                runat="server" /></p>
                    </asp:Panel>
                </LoggedInTemplate>
                <AnonymousTemplate>
                    <asp:HyperLink ID="lnkLogin" CssClass="needToLogInComp" runat="server" />
                </AnonymousTemplate>
            </asp:LoginView>
        <asp:UpdatePanel ID="updSelected" UpdateMode="Conditional" runat="server">
        <ContentTemplate>
            <asp:Panel ID="pnlSuspended" CssClass="htmlArticleWide" Visible="false" runat="server">
                <div class="compImageSelected">
                    <asp:Image ID="imgSuspended" ImageUrl="~/img/suspended-image.gif" AlternateText="Suspended Entrant" runat="server" />
                </div>
            </asp:Panel>
            <asp:Panel ID="pnlSelected" CssClass="htmlArticleWide" Visible="true" runat="server"
                OnDataBinding="pnlSelected_DataBinding">
                <div>
                    <asp:Label ID="lblUserName" CssClass="commentUserName" runat="server" />
                    @
                    <asp:Label ID="lblCreatedTime" runat="server" />
                </div>
                <div class="compImageSelected">
                    <acms:AcmsImage ID="imgSelected" RenderHeight="452" RenderWidth="452" runat="server" />
                </div>
                <div class="compImageSelectedTitle">
                    <asp:Label ID="lblTitle" runat="server"></asp:Label>
                </div>
                <div class="compImageSelectedComment">
                    <asp:Literal ID="litComment" runat="server" />
                </div>
                <div style="clear:both"></div>
                <asp:Panel ID="pnlYourRating" Style="float: left;" runat="server">
                    Your Rating:
                    <ajaxToolkit:Rating ID="yourRating" MaxRating="5" AutoPostBack="true" runat="server"
                        CurrentRating="0" EmptyStarCssClass="emptyRatingStar" FilledStarCssClass="filledRatingStar"
                        StarCssClass="ratingStar" WaitingStarCssClass="savedRatingStar" OnChanged="yourRating_Changed" />
                </asp:Panel>
                <asp:Panel ID="pnlAveRating" Style="float: right" runat="server">
                    Average Rating:
                    <ajaxToolkit:Rating ID="aveRating" MaxRating="5" runat="server"
                        CurrentRating="0" ReadOnly="true" EmptyStarCssClass="emptyRatingStar" FilledStarCssClass="filledRatingStar"
                        StarCssClass="ratingStar" WaitingStarCssClass="savedRatingStar" />
                </asp:Panel>
                <div style="text-align:center;">
                    <asp:LinkButton ID="btnReport" Text="Report this entry as unsuitable." runat="server" OnClick="btnReport_Click"/>
                    <asp:Label ID="lblReported" Text="This entrant has been reported as unsuitable." runat="server" />
                </div>
                <div style="clear: both">
                </div>
            </asp:Panel>
        </ContentTemplate>
    </asp:UpdatePanel>
    <div class="htmlArticleWide">
        <div style="clear:both"></div>
        <h3>Current Entries - select a picture</h3>
        <asp:UpdatePanel ID="updEntrants" UpdateMode="Conditional" ChildrenAsTriggers="false"
            runat="server">
            <ContentTemplate>
                <acms:AcmsDataList ID="dlEntrants" UseAjax="true" DataSourceID="dsEntrants" AllowPaging="true"
                    PageSize="9" runat="server" OnItemCommand="dlEntrants_ItemCommand" OnItemDataBound="dlEntrants_ItemDataBound">
                    <NoDataStyle CssClass="htmlArticle" />
                    <NoDataTemplate>
                        There are currently no entrants to this competition.
                    </NoDataTemplate>
                    <SeperatorStyle CssClass="CompImgItemEndRow" />
                    <SeperatorTemplate>
                    </SeperatorTemplate>
                    <FooterStyle CssClass="CompImgItemEndRow" />
                    <FooterTemplate>
                    </FooterTemplate>
                    <ItemStyle CssClass="CompImgItem" />
                    <ItemTemplate>
                        <span>
                            <asp:Image id="imgSuspended" ImageUrl="~/img/suspended-thumbnail.gif" ToolTip="Suspended Image" runat="server" />
                            <asp:ImageButton id="imgReported" ImageUrl="~/img/reported-thumbnail.gif" TootlTip="This image has been reported as unsuitable" CommandName="Show" CommandArgument='<%#Eval("Id")%>' runat="server" />
                            <acms:AcmsImageLinkButton ID="imgThumb" RenderHeight="130" RenderWidth="130" FileId='<%#Eval("FileId")%>'
                                ToolTip='<%#Eval("Title")%>' CommandName="Show" CommandArgument='<%#Eval("Id")%>'
                                runat="server" />
                        </span>
                    </ItemTemplate>
                </acms:AcmsDataList>
            </ContentTemplate>
        </asp:UpdatePanel>
        <acms:UserPostUploadDataSource ID="dsEntrants" OnSelectData="dsEntrants_SelectData"
            runat="server" />
    </div>
</asp:Content>
